package uk.ac.glasgow.demosocs.tests;

import static org.junit.Assert.*;

import java.util.Date;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import uk.ac.glasgow.demosocs.Election;
import uk.ac.glasgow.demosocs.VotingSystem;
import uk.ac.glasgow.demosocs.impl.VotingSystemStub;
public class SetElection {
	
	private VotingSystem testVS;
	
	@Before
	public void setUp() throws Exception {
		testVS = new VotingSystemStub();

		testVS.setCurrentUser("admin", "p");
		testVS.createElection("oldE", "Simple_Plurality");
		testVS.editElection(new Date(), new Date(), new Date(), "Level_3");
		
	}

	@After
	public void tearDown() throws Exception {
		testVS = null;
	}

	@Test
	/** tries to set the current election 
	 *  if the EID is valid then the old current election
	 *  should be different to the new current election
	 */
	public void test() {
		Election e = testVS.getCurrentElection(); //get the old cur election
		System.out.println(e.getEID());
		testVS.createElection("testE", "Simple_Plurality"); //creates and sets a new current election
		testVS.editElection(new Date(), new Date(), new Date(), "Level_3");
		Election oldE = testVS.getCurrentElection(); //the old current election
		testVS.setCurrentElection(e.getEID()); //sets the current election
		e = testVS.getCurrentElection(); //gets the new current elections
		boolean result = oldE.equals(e); //compares them
		assertFalse(result); //they should be different so passes if false

	}

}
